{%- set image = salt['pillar.get']('default:OMV_PHOTOPRISM_DB_CONTAINER_IMAGE', 'docker.io/mariadb:latest') -%}
{%- set options = salt['pillar.get']('default:OMV_PHOTOPRISM_DB_CONTAINER_START_OPTIONS', '') -%}
{%- set appdata_path = salt['omv_conf.get_sharedfolder_path'](config.appdata_sharedfolderref) -%}
{%- set appdata_mnt_path = salt['omv_conf.get_sharedfolder_mount_path'](config.appdata_sharedfolderref) -%}
{{ pillar['headers']['multiline'] -}}
[Unit]
Description=Podman container-photoprism-db.service
Wants=network.target
After=network-online.target
BindsTo=pod-photoprism.service
After=pod-photoprism.service
RequiresMountsFor="{{ appdata_mnt_path }}"

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/container-photoprism-db.pid %t/container-photoprism-db.ctr-id
ExecStart=/usr/bin/podman run --conmon-pidfile %t/container-photoprism-db.pid --cidfile %t/container-photoprism-db.ctr-id --cgroups=no-conmon --pod-id-file %t/pod-photoprism.pod-id -d --replace --pull=never --name=photoprism-db -e MYSQL_DATABASE=photoprism -e MYSQL_USER=photoprism -e MYSQL_PASSWORD=photoprism -e MYSQL_ROOT_PASSWORD=photoprism -v "{{ appdata_path }}/db/":/var/lib/mysql/ {{ options }} {{ image }}
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-photoprism-db.ctr-id
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-photoprism-db.ctr-id
PIDFile=%t/container-photoprism-db.pid
Type=forking

[Install]
WantedBy=multi-user.target default.target
